define(['store'], function (store) {
    'use strict';
    function ctrl($scope, $state, DictionaryService) {
        function init() {
            $scope.relationships = DictionaryService.getRelationshipAds();
            $scope.selectRelationship = {
                val: store.get('SignInfo').relationship.val
            };

        }

        $scope.$on('$ionicView.beforeEnter', function () {
            init();

        });

        $scope.change = function () {
            var relText;
            for (var i = 0; i < $scope.relationships.length; i++) {
                if ($scope.selectRelationship.val == $scope.relationships[i].val) {
                    relText = $scope.relationships[i].text;
                    var signInfo = store.get('SignInfo');
                    signInfo.relationship = {text: relText, val: $scope.selectRelationship.val};
                    store.set('SignInfo', signInfo);
                    return;
                }
            }
        };
        $scope.onBackKeyDown = function () {
            $state.go('tab.account-sign');
        }
    }

    ctrl.$inject = ['$scope', '$state', 'DictionaryService'];
    return ctrl;
});